package com.knowif.service;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.knowif.dao.UserItemMapper;
import com.knowif.pojo.UserItem;
import com.knowif.pojo.UserItemExample;

@Service
public class UserItem_service {
	
	@Autowired
	private UserItemMapper userItemMapper;
	
	
	public List<UserItem> selectUserItem(UserItemExample example){
		return userItemMapper.selectByExample(example);
	}
	
	
	
	public List<UserItem> selectUserItemById(Integer itemId){
		if(itemId == null){
			return new ArrayList<UserItem>();
		}
		UserItemExample userItemExample = new UserItemExample();
		userItemExample.createCriteria().andItemIdEqualTo(itemId);
		return userItemMapper.selectByExample(userItemExample);
	}

	public List<UserItem> selectByUserIds(List<Integer> userIds){
		if(userIds == null || userIds.isEmpty()){
			return new ArrayList<UserItem>();
		}
		UserItemExample userItemExample = new UserItemExample();
		userItemExample.createCriteria().andUserIdIn(userIds);
		return userItemMapper.selectByExample(userItemExample);
	}
}
